package com.cw.jeeyt.service.converter.facade;

import java.util.List;

import com.cw.jeeyt.service.bo.facade.FacadeClassBo;
import com.cw.jeeyt.dao.model.facade.FacadeClassDo;
import com.cw.lang.common.utils.CollectionUtil;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;

/**
 * 接口类转换类
 *
 * @author chenw
 * @date 2019-11-02 14:16:40
 */
public class FacadeClassConverter {

    /**
    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static FacadeClassBo do2Bo(FacadeClassDo model) {
        if (model == null) {
            return null;
        }
        return FacadeClassBo.builder()
            .id(model.getId())
            .classCode(model.getClassCode())
            .className(model.getClassName())
            .projectId(model.getProjectId())
            .isPublic(model.getIsPublic())
            .facadeDesc(model.getFacadeDesc())
            .createBy(model.getCreateBy())
            .createDate(model.getCreateDate())
            .updateBy(model.getUpdateBy())
            .updateDate(model.getUpdateDate())
            .build();
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static FacadeClassDo bo2Do(FacadeClassBo bo) {
        if (bo == null) {
            return null;
        }
        FacadeClassDo model = new FacadeClassDo();
        model.setId(bo.getId());
        model.setClassCode(bo.getClassCode());
        model.setClassName(bo.getClassName());
        model.setProjectId(bo.getProjectId());
        model.setIsPublic(bo.getIsPublic());
        model.setFacadeDesc(bo.getFacadeDesc());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<FacadeClassBo> doList2BoList(List<FacadeClassDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(),FacadeClassConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<FacadeClassDo> boList2DoList(List<FacadeClassBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return null;
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(),FacadeClassConverter::bo2Do));
    }

}
